<?php
class Register_Index_Action extends NICED_Action 
{       
	public function execute() 
	{
		$controller = $this->getController();
		$request    = $controller->getRequest();			
        $user_name = $request->loadParam("user_name", NULL, "safe");
        $password  = $request->loadParam("password", NULL, "safe");
        $email     = $request->loadParam("email", NULL, "safe");
        $act       = $request->loadParam("act", NULL, "safe");

		try
		{
			$model   = $controller->getModel('Register.Index');
            if ($act)
            {
			    $bool = $model->register($user_name, $password, $email);
                if ($bool)
                {
                    echo "注册成功<a href='".NICED_URL::buildURL("landing.home")."'>回首页</a>";
                }
            }
		}
		catch (Exception $e)
		{
			if ("Exception" == get_class($e))
            {
                $e = new NICED_Exception($e->getMessage());
            }

			$controller->handleException($e);
			return self::SUCCESS;
		}

		return self::SUCCESS;
	}

}//end class
